import React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { setName, setInfo, cyName, cyInfo } from '../../store/slicers/studentSlice.js'
function index() {
    const name = useSelector(cyName)
    const info = useSelector(cyInfo)
    const dispatch=useDispatch()
    const gaiName=()=>{
        dispatch(setName('嘿嘿'))
    }
    const gaiInfo=()=>{
        dispatch(setInfo({sex:"女",age:3}))
    }
    return (
        <div>
            <p>姓名:{name}</p>
            <p>性别:{info.sex}</p>
            <p>年龄:{info.age}</p>
            <button onClick={gaiName}>修改名字</button>
            <button onClick={gaiInfo}>修改Info</button>
        </div>
    )
}

export default index
